﻿using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using UnityEditor.UI;
/// <summary>
/// 直接继承HorizontalOrVerticalLayoutGroupEditor会有问题，但使用Editor反而不会
/// </summary>
[CustomEditor(typeof(AutoSizeVerticalLayoutGroup))]
[CanEditMultipleObjects]
public class AutoSizeVerticalLayoutGroupEditor :Editor
    //: HorizontalOrVerticalLayoutGroupEditor
{
    SerializedProperty m_AutoFitHeight;
    SerializedProperty m_AutoFitWidth;

    protected void OnEnable()
    {
        //base.OnEnable();
        m_AutoFitHeight = serializedObject.FindProperty("m_AutoFitHeight");
        m_AutoFitWidth = serializedObject.FindProperty("m_AutoFitWidth");
    }

    public override void OnInspectorGUI()
    {
        //serializedObject.Update();

        //// 显示Auto Size设置
        //EditorGUILayout.LabelField("Auto Size Settings", EditorStyles.boldLabel);
        //EditorGUILayout.PropertyField(m_AutoFitHeight, new GUIContent("Auto Fit Height"));
        //EditorGUILayout.PropertyField(m_AutoFitWidth, new GUIContent("Auto Fit Width"));

        //EditorGUILayout.Space();

        // 显示原有的Layout Group设置
        base.OnInspectorGUI();

        //serializedObject.ApplyModifiedProperties();
    }

    //public override void OnInspectorGUI()
    //{
    //    serializedObject.Update();

    //    // 显示Auto Size设置
    //    EditorGUILayout.LabelField("Auto Size Settings", EditorStyles.boldLabel);
    //    EditorGUILayout.PropertyField(m_AutoFitHeight, new GUIContent("Auto Fit Height"));
    //    EditorGUILayout.PropertyField(m_AutoFitWidth, new GUIContent("Auto Fit Width"));

    //    EditorGUILayout.Space();

    //    // 显示原有的Layout Group设置
    //    base.OnInspectorGUI();

    //    serializedObject.ApplyModifiedProperties();
    //}
}